package com.fingard.remoting.server;

import com.fingard.text.StringHelper;
import com.fingard.xml.XElement;

public class TenantItem {
/*	<tenant>
	    <id readme="对应报文中的Tenant节点，需唯一">123</id>
	    <code readme="远程代理端租户代码，需唯一">zjsdyx</code>
	    <name>时代院线</name>
	    <publicKey readme="租户公钥"></publicKey>
	    <maxLinks readme="允许同时保持的最大连接数">2</maxLinks>
	    <srcIps readme="来源ip列表">*</srcIps>
	</tenant>*/
	public String id;
	public String code;
	public String name;
	public String publicKey;
	public int maxLinks;
	public String srcIps;
	
	public void fromXElement(XElement pXe) throws Exception{
		id = pXe.getSingleTextNotNull("id");
		code = pXe.getSingleTextNotNull("code");
		name = pXe.getSingleTextNotNull("name");
		publicKey = pXe.getSingleTextNotNull("publicKey");
		String strMax = pXe.getSingleTextNotNull("maxLinks");
		if(StringHelper.hasAnyChar(strMax)){
			maxLinks = Integer.parseInt(strMax);
		}else{
			maxLinks = 2;
		}
		srcIps = pXe.getSingleTextNotNull("srcIps");
	}
}
